﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZF.BLL;
using GCELibrary.Current;

namespace ZF.WS.expert
{
    public partial class mpexpert :BLL.Page.MasterPage
    {
        public Model.US_Member Expert { get; set; }
        public string EType
        {
            get
            {
                return DictionaryConfig.EExpertType.FirstOrDefault(p => p.Key == Expert.ExpertType).Text;
            }
        }
        [PageArgument(Key = "id", CanNull = false)]
        public int Id { get; set; }
        public int ArticleCount { get; set; }
        public int EstateCount { get; set; }
        public static Random Random = new Random();
        protected void Page_Load(object sender, EventArgs e)
        {
            using (var dc = SiteInfo.CreateDBDataContext())
            {
                Expert = dc.US_Member.FirstOrDefault(p => p.MemberId == Id && p.IsExpert);

                if (Expert == null)
                {
                    throw WarnFactory.CreateWarn(WarnCode.ReocrdNoFind);
                }
                ArticleCount = Expert.E_Article.Count;
                EstateCount = dc.H_Estate.Where(p => p.IsVerify).Where(p => p.MemberId == Id).Count();
                Expert.Hits++;
                dc.SubmitChanges();


                foreach (View view in this.mvList.Views)
                {
                    if (view is BLL.UserControls.View && ((BLL.UserControls.View)view).Key == Expert.ExpertType.ToString())
                    {
                        mvList.SetActiveView(view); break;
                    }
                }

            }

        }
    }
}
